﻿using myAC.DataProviders;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myAC.TLC
{
    public class DataBroker
    {
        static List<String> classLabels; // SupportTopicDerivedId sequence number ~ class#

        /// <summary>
        /// Iterate through data instnaces and generate a txt input file for TLC.
        /// _SRNumber   Label   Title   Body
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="instances"></param>
        //public static void GenerateInputData(List<SR> srs, String filePath)
        //{
        //    classLabels = GenerateLabels(srs);
        //    StringBuilder sb = new StringBuilder();
        //    String instance = "_{0}\t{1}\t{2}\t{3}";
        //    filePath = DateTime.Now.Ticks.ToString() + "." + filePath;
        //    Int32 lineCount = 0;
        //    foreach(SR sr in srs)
        //    {
        //        String srNumber = sr.SrNumber;
        //        String label = classLabels.IndexOf(sr.Topic.SupportTopicDerivedId).ToString();
        //        String title = sr.ProcessedExternalTitle;
        //        String body = sr.ProcessedBody;
        //        sb.AppendLine(String.Format(instance, srNumber, label, title, body));
        //        lineCount++;
        //        if (lineCount == 50)
        //        {
        //            File.AppendAllText(filePath, sb.ToString());
        //            sb.Clear();
        //            lineCount = 0;
        //        }
        //    }
        //}

        //private static List<String> GenerateLabels(List<SR> srs)
        //{
        //    List<String> distinctSupportTopicDerivedIds = srs.GroupBy(sr => sr.Topic.SupportTopicDerivedId).Select(group => group.Key).ToList();
        //    return distinctSupportTopicDerivedIds;  // the topics which have no SRs is not included here.
        //}
    }
}
